package com.dios.mirage.component.fields;

import java.io.InputStream;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.decor.BackgroundFactory;

import com.dios.mirage.navigation.Navigation;

public class NavigationScreenPopupField extends LabelField {

	private PopupScreen popScreen;
	private Screen pushScreen;

	public NavigationScreenPopupField(String text, Screen pushScreen,
			PopupScreen popScreen) {
		super(text, Field.FOCUSABLE);
		this.pushScreen = pushScreen;
		this.popScreen = popScreen;
		init();
	}

	protected boolean navigationClick(int status, int time) {
		UiApplication.getUiApplication().popScreen(popScreen);
		UiApplication.getUiApplication().pushScreen(pushScreen);
		return super.navigationClick(status, time);
	}

	private void init() {
		setBackground(BackgroundFactory.createSolidBackground(Color.BLACK));
		InputStream stream = getClass().getResourceAsStream(
				"/font/Gotham-Bold.woff");
		setFont(Navigation.loadCustomFonts(stream, Font.BOLD, 30));
		setMargin(0, 0, 0, 0);
	}

}
